<?php
/**
 * +-------------------------------------------------------------
 * |Caption:
 * +-------------------------------------------------------------
 * |Author: Lenny
 * +-------------------------------------------------------------
 * |Email:  1685964109@qq.com
 * +-------------------------------------------------------------
 * |Date:   2024/7/3 下午7:33
 * +-------------------------------------------------------------
 */

namespace app\admin\controller;

use app\admin\validate\ProductValidate;
use app\common\controller\AdminController;
use think\App;
use app\admin\service\annotation\ControllerAnnotation;
use app\admin\model\Product as ModelProduct;

/**
 * @ControllerAnnotation (title="产品管理")
 */
class Product extends AdminController
{
    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->model           = new ModelProduct();
        $this->relationSearch  = true;
        $this->joinTable       = 'cate';
        $this->joinDelTable    = 'specs';
        $this->isListEach      = true;
        $this->validateClass   = ProductValidate::class;
        $this->joinAddTable    = 'specs';
        $this->joinUpdateTable = 'specs';
    }

    /**
     * 列表数据处理
     */
    public function format($list)
    {
        return $list->each(function ($item){
            $item->specs = $item->specs()->select();
        });
    }

}